<?php
	
	if($_POST['act']=='op')
	{
		if(is_array($_POST['chk']))
		{
			$id=implode(",",$_POST['chk']);
			$sql="delete from ".SPOT." where id in ($id)";
			$db->query($sql);
			msg("?m=spot&s=spot.php");
		}
	}
	if($_GET['name'])
	{
		$psql=" and s.spot_name like '%$_GET[name]%' ";
	}

	$sql="SELECT s.*,c.cat_name FROM ".SPOT." s left join ".SPOTCAT." c on s.cat_id = c.id WHERE 1 $psql order by s.id desc";
	//====================
	include_once("../includes/page_utf_class.php");
	$page = new Page;
	$page->listRows=20;
	if (!$page->__get('totalRows')){
		$db->query($sql);
		$de['count']=$page->totalRows = $db->num_rows();
	}
	$de['count']=$de['count']?$de['count']:$page->__get('totalRows');
	$sql .= "  limit ".$page->firstRow.",".$page->listRows;
	$de['page'] = $page->prompt();
	//=====================
	$db->query($sql);
	$de['list']=$db->getRows();

	unset($_GET['s']);
	$tpl->assign("url",'&'.implode('&',convert($_GET)));
	$tpl->assign("de",$de);
	$tpl->assign("config",$config);
	$tpl->display("spot.htm");
?>